/**
 * @param {number} rowIndex
 * @return {number[]}
 */
var getRow = function(rowIndex) {
    let res = []
    for(let i=0;i<=rowIndex;i++){
        res[i] = []
        for(let j=0;j<=i;j++){
            if(j===0||j===i){
                res[i][j] = 1
            }else{
                res[i][j] = res[i-1][j-1] + res[i-1][j]
            }
        }
    }
    return res[rowIndex]
};

console.log(getRow(4));